﻿module Enferno.Public.Web.Components.Models {

    export class ProductVariantModel {
        public id: number;
        public name: string;
        public displayPrice: number;
        public catalogPrice: number;
        public partNo: string;
        public priceListId: number;
        public onHandStatusText1: string;
        public onHandStatusText2: string;
        public onHandStatusCount: number;
        public files: Array<FileInfoModel>;
        public variantParametrics: Array<ParametricModel>;


        constructor(serverData?: any) {
            this.variantParametrics = new Array<ParametricModel>();
            this.files = new Array<FileInfoModel>();

            if (serverData != null) {
                this.id = serverData.id;
                this.name = serverData.name;
                this.displayPrice = serverData.displayPrice;
                this.catalogPrice = serverData.catalogPrice;
                this.partNo = serverData.partNo;
                this.priceListId = serverData.priceListId;
                this.onHandStatusText1 = serverData.onHandStatusText1;
                this.onHandStatusText2 = serverData.onHandStatusText2;
                this.onHandStatusCount = serverData.onHandStatusCount;

                if (serverData.files != null) {
                    Enumerable.from(serverData.files).forEach(file => this.files.push(new FileInfoModel(file)));
                }

                Enumerable.from(serverData.variantParametrics).forEach(parametric => this.variantParametrics.push(new ParametricModel(parametric)));
            }
        }
    }

} 